
package com.dinotrack.domain;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author alquad
 */
public class AlbumSQL {
    
    Session session=null;
    
    public AlbumSQL()
    {
        session=HibernateUtil.getSessionFactory().getCurrentSession();
    }
    
    public void getAlbums()
    {
        List<Album> albums=null;
        
        try {
        org.hibernate.Transaction tx = session.beginTransaction();
        Query q = session.createQuery ("from Album");
        albums = (List<Album>) q.list();

    } catch (Exception e) {
        e.printStackTrace();
    }

        System.out.println("albums = "+albums.size());
        int i;
        
        for(i=0;i<albums.size();i++)
            System.out.println(albums.get(i).getNombre());
        
    }
}
